package domain.model;

import java.text.DecimalFormat;
import java.util.Random;

public final class RekenFuncties {
	
	public double btwZes(double getal)
	{
		double output = afrondenValutaDouble(getal * 1.06);
		return output;
	}
	
	public double btwTwaalf(double getal)
	{
		double output = afrondenValutaDouble(getal * 1.12);
		return output;
	}
	
	public double btwEenentwintig(double getal)
	{
		double output = afrondenValutaDouble(getal * 1.21);
		return output;
	}
	
	public String afrondenValutaTekst(double getal)
	{
		DecimalFormat df = new DecimalFormat("###.##");
		String output = df.format(getal);
		return output;
	}
	
	public double afrondenValutaDouble(double getal)
	{
		double output = 0;
		
		output = Math.round(getal*100.0)/100.0;
		
		return output;
	}
	
	public int generateRandom(int bovengrens, int ondergrens)
	{
		int output = 0;
		
		Random random = new Random();
		output = showRandomInteger(ondergrens, bovengrens, random);
		
		
		
		return output;
	}
	
	private int showRandomInteger(int aStart, int aEnd, Random aRandom){
	    if ( aStart > aEnd ) {
	      throw new IllegalArgumentException("Start cannot exceed End.");
	    }
	    //get the range, casting to long to avoid overflow problems
	    long range = (long)aEnd - (long)aStart + 1;
	    // compute a fraction of the range, 0 <= frac < range
	    long fraction = (long)(range * aRandom.nextDouble());
	    int randomNumber =  (int)(fraction + aStart);
	    
	    return randomNumber;
	  }

}
